using UnityEngine;
using Voodoo.Sauce.Core;
using Voodoo.Sauce.Internal.Analytics;
using Voodoo.Sauce.Internal.StoreUtility;
using Voodoo.Sauce.Privacy;

namespace Voodoo.Sauce.Debugger
{
	public class GeneralInfoDebugScreen : Screen
	{
		private void OnEnable()
		{
			ClearDisplay();
			VoodooSettings settings = VoodooSettings.Load();
			ShowVSInfo(settings);
			ShowDevInfo();
			ShowDeviceInfo();
			ShowLoadingTimes();
		}

		private void ShowVSInfo(VoodooSettings settings)
		{
		}

		private void ShowDevInfo()
		{
			OpenFoldout("Development");
			CopyToClipboard("Unity version", Application.unityVersion);
			CopyToClipboard("Bundle ID", Application.identifier);
			CopyToClipboard("Version", Application.version);
			CopyToClipboard("Build", AppInfo.GetVersionCode().ToString());
			CloseFoldout();
		}

		private void ShowDeviceInfo()
		{
			PrivacyCore privacy = VoodooSauceCore.GetPrivacy();
			OpenFoldout("Device");
			CopyToClipboard("IDFA", privacy.GetAdvertisingId());
			CopyToClipboard("Voodoo User ID", AnalyticsUserIdHelper.GetUserId());
			CopyToClipboard("Device UID", SystemInfo.deviceUniqueIdentifier);
			CopyToClipboard("Operating System", SystemInfo.operatingSystem);
			CloseFoldout();
		}

		private void ShowLoadingTimes()
		{
		}

		private static string FormattedLoadingTime(long time)
		{
			if (time < 1000)
			{
				return $"{time} ms";
			}
			return $"{(double)time / 1000.0:0.##} s";
		}
	}
}
